// ===============================================================================
// scan: sequential scan of a large descriptor collection
// Created in September 2007 as a project for an Advanced Database Systems course
// (c) Reykjavik University, Björn Þór Jónsson, Kristleifur Daðason, Herwig Lejsek
// Contact author: Björn Þór Jónsson, Reykjavík University, bjorn@ru.is
// ===============================================================================

#include "ConfigMapper.h"

ConfigMapper::ConfigMapper(string filename)
{
	// Open the file
	FILE *file = fopen(filename.c_str(), "rb");
	if (errno != 0) 	{
		cout << "ConfigMapper (" << filename << ")" << endl;
		cout << "fopen error: " << errno << ": " << strerror(errno) << endl;
		exit(0);
	}

	// Get the lines from the file one by one
	char stemp[1000];
	int  itemp;

	// 1) type -- ignore
	fscanf(file, "type: %s\n", &stemp);

	// 2) dims
	fscanf(file, "dims: %i\n", &itemp);
	numDims = itemp;

	// 3) clst -- ignore
	fscanf(file, "clst: %i\n", &itemp);

	// 4) indx path
	fscanf(file, "indx: %s\n", &stemp);
	indxPath = stemp;

	// 5) data path
	fscanf(file, "data: %s\n", &stemp);
	dataPath = stemp;

	// 6) page size
	fscanf(file, "page: %i\n", &itemp);
	pageSize = itemp;

	// 7) image count
	fscanf(file, "imgs: %i\n", &itemp);
	numImages = itemp;

	// Done reading, so close the file
	fclose(file);
};

ConfigMapper::~ConfigMapper()
{
}
